package com.yuwei.base.view

import android.os.Bundle
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import androidx.databinding.DataBindingUtil
import androidx.databinding.ViewDataBinding
import androidx.fragment.app.Fragment
import com.blankj.utilcode.util.ToastUtils

open abstract class BaseMVVMFragment<VDB:ViewDataBinding>:Fragment() {
    protected lateinit var binding:VDB
    override fun onCreateView(
        inflater: LayoutInflater,
        container: ViewGroup?,
        savedInstanceState: Bundle?
    ): View? {
        //获取布局的代理对象
        binding = DataBindingUtil.inflate(inflater,getLayoutId(),container,false)
        return binding.root
    }
    protected fun showToast(msg:String){
        if (msg.isEmpty()){
            ToastUtils.showLong(msg)
        }
    }

    abstract fun getLayoutId(): Int
}